<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<xsl:stylesheet 
	version="1.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	xmlns:msxml="urn:schemas-microsoft-com:xslt"
	xmlns:umbraco.library="urn:umbraco.library" 
    xmlns:filesystem="urn:filesystem" 
	exclude-result-prefixes="msxml umbraco.library filesystem ">


  <xsl:output method="xml" omit-xml-declaration="yes"/>

  <xsl:variable name="field" select="/macro/field" />

  <xsl:param name="currentPage"/>

  <xsl:template match="/">
    <xsl:if test="string-length($currentPage/*[not(isDoc) and local-name() = $field]) &gt; 0">
      <xsl:variable name="file" select="filesystem:GetMedia($currentPage/*[not(isDoc) and local-name() = $field]/value/@dataTypeId, $currentPage/*[not(isDoc) and local-name() = $field]/value)" />
      <a href="{$file/Url}" title="{$file/Name}"><xsl:value-of select="$file/Name" /></a>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>